Imports System.Text.RegularExpressions

Public Class frmAddNewResourceType
    Inherits System.Windows.Forms.Form

    ' this is seperate from the resource picker because it is so basic

    Private mvarCancelPressed As Boolean = False
    Private ptrItem As cmplib01.ResourceType
    Private numericalCheck As Regex

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents pnlProperties As System.Windows.Forms.Panel
    Friend WithEvents txtResourceTypeName As System.Windows.Forms.TextBox
    Friend WithEvents lblRuleTypeName As System.Windows.Forms.Label
    Friend WithEvents txtResourceDescription As System.Windows.Forms.TextBox
    Friend WithEvents lblResourceText As System.Windows.Forms.Label
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents btnOK As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmAddNewResourceType))
        Me.pnlProperties = New System.Windows.Forms.Panel()
        Me.txtResourceTypeName = New System.Windows.Forms.TextBox()
        Me.lblRuleTypeName = New System.Windows.Forms.Label()
        Me.txtResourceDescription = New System.Windows.Forms.TextBox()
        Me.lblResourceText = New System.Windows.Forms.Label()
        Me.btnCancel = New System.Windows.Forms.Button()
        Me.btnOK = New System.Windows.Forms.Button()
        Me.pnlProperties.SuspendLayout()
        Me.SuspendLayout()
        '
        'pnlProperties
        '
        Me.pnlProperties.BackColor = System.Drawing.SystemColors.ControlLight
        Me.pnlProperties.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlProperties.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtResourceTypeName, Me.lblRuleTypeName, Me.txtResourceDescription, Me.lblResourceText})
        Me.pnlProperties.Location = New System.Drawing.Point(8, 8)
        Me.pnlProperties.Name = "pnlProperties"
        Me.pnlProperties.Size = New System.Drawing.Size(192, 136)
        Me.pnlProperties.TabIndex = 3
        '
        'txtResourceTypeName
        '
        Me.txtResourceTypeName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtResourceTypeName.Location = New System.Drawing.Point(79, 8)
        Me.txtResourceTypeName.Name = "txtResourceTypeName"
        Me.txtResourceTypeName.Size = New System.Drawing.Size(104, 20)
        Me.txtResourceTypeName.TabIndex = 0
        Me.txtResourceTypeName.Text = "New Resource"
        '
        'lblRuleTypeName
        '
        Me.lblRuleTypeName.Location = New System.Drawing.Point(7, 11)
        Me.lblRuleTypeName.Name = "lblRuleTypeName"
        Me.lblRuleTypeName.Size = New System.Drawing.Size(72, 16)
        Me.lblRuleTypeName.TabIndex = 10
        Me.lblRuleTypeName.Text = "Type Name"
        Me.lblRuleTypeName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'txtResourceDescription
        '
        Me.txtResourceDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtResourceDescription.Location = New System.Drawing.Point(8, 56)
        Me.txtResourceDescription.Multiline = True
        Me.txtResourceDescription.Name = "txtResourceDescription"
        Me.txtResourceDescription.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtResourceDescription.Size = New System.Drawing.Size(176, 64)
        Me.txtResourceDescription.TabIndex = 1
        Me.txtResourceDescription.Text = "Enter a description."
        '
        'lblResourceText
        '
        Me.lblResourceText.Location = New System.Drawing.Point(8, 40)
        Me.lblResourceText.Name = "lblResourceText"
        Me.lblResourceText.Size = New System.Drawing.Size(96, 16)
        Me.lblResourceText.TabIndex = 8
        Me.lblResourceText.Text = "Resource Text"
        '
        'btnCancel
        '
        Me.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnCancel.Location = New System.Drawing.Point(136, 152)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(56, 23)
        Me.btnCancel.TabIndex = 3
        Me.btnCancel.Text = "Cancel"
        '
        'btnOK
        '
        Me.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnOK.Location = New System.Drawing.Point(72, 152)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(56, 23)
        Me.btnOK.TabIndex = 2
        Me.btnOK.Text = "OK"
        '
        'frmAddNewResourceType
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(208, 182)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnCancel, Me.btnOK, Me.pnlProperties})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmAddNewResourceType"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.Text = "Resource Type"
        Me.pnlProperties.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Sub New(ByRef newResourceType As cmplib01.ResourceType, Optional ByVal forEdit As Boolean = False)
        Me.New()
        ptrItem = newResourceType
        If forEdit Then txtResourceTypeName.Enabled = False
        populate()
    End Sub

    Private Sub populate()
        txtResourceTypeName.Text = ptrItem.ResourceName
        txtResourceDescription.Text = ptrItem.ResourceDescription
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        mvarCancelPressed = True
        Me.Hide()
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        ' save the properties
        ptrItem.ResourceName = txtResourceTypeName.Text.ToString
        ptrItem.ResourceDescription = txtResourceDescription.Text.ToString
        mvarCancelPressed = False
        Me.Hide()
    End Sub

    Public ReadOnly Property CancelPressed() As Boolean
        Get
            Return mvarCancelPressed
        End Get
    End Property

End Class
